﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CustomValidatorExample.aspx.cs"
    Inherits="Lesson01.CustomValidatorExample" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function ValidatePassword(sender, arguments) {
            if (sender == 'undefined' || arguments == 'undefined')
                return;
            arguments.IsValid = false;
            if (arguments.Value == undefined)
                return;
            if (arguments.Value.length < 6 || arguments.Value.length > 14)
                return;
            arguments.IsValid = true;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label Text="Please enter your password<br/>with 6-14 characters length" runat="server" />
        <asp:TextBox ID="txtPassword" TextMode="Password" runat="server" />
<%--        <asp:CustomValidator Text="Password is invalid" ControlToValidate="txtPassword" runat="server"
            ClientValidationFunction="ValidatePassword" OnServerValidate="CustomValidator_ServerValidate" />--%>
        <asp:CustomValidator ID="CustomValidator1" Text="Password is invalid" ControlToValidate="txtPassword"
            runat="server" ClientValidationFunction="ValidatePassword" OnServerValidate="CustomValidator_ServerValidate" />
        <br />
        <asp:Button Text="Submit" runat="server" />
    </div>
    </form>
</body>
</html>
